﻿using UnityEngine;
using System.Collections;

[AddComponentMenu("NGUI/Tween/Position One Axis")]
public class TweenPositionOneAxis : TweenPosition {

	public bool xAxis = false;
	public bool yAxis = false;
	public bool zAxis = false;
	
	Vector3 temp;
	
	protected override void OnUpdate (float factor, bool isFinished)
	{
		temp = from * (1f - factor) + to * factor;
		temp.x = xAxis ? cachedTransform.localPosition.x : temp.x;
		temp.y = yAxis ? cachedTransform.localPosition.y : temp.y;
		temp.z = zAxis ? cachedTransform.localPosition.z : temp.z;
		
		cachedTransform.localPosition = temp;
	}
}
